package com.jacken.mars.controller.tool;

import com.jacken.mars.commons.annotation.BaseAnnotationNote;
import com.jacken.mars.entity.db.GenTable;
import com.jacken.mars.entity.resp.R;
import com.jacken.mars.service.IGenTableService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @version: 2.4.5
 * @author: wq
 * @time: 2021/2/5 11:26
 */
@RestController
@RequestMapping("/admin/code/table")
@AllArgsConstructor
public class GenController {


    private final IGenTableService genTableService;

    /**
     * 数据库表列表
     *
     * @param genTable
     * @return
     */
    @PostMapping("/list")
    @BaseAnnotationNote
    public R tableList(@RequestBody GenTable genTable) {
        return R.success(genTableService.selectDbTableList(genTable));
    }

    /**
     * 代码生成
     *
     * @return
     */
    @GetMapping("/genCode")
    @BaseAnnotationNote
    public R genCode(String tableName) {
        genTableService.genCode(tableName);
        return R.success("生成成功");
    }


}
